﻿using System;
using System.Windows;

namespace ExampleApp1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        //Hooks objects
        private WinHooksNET.KeyboardHook _keyboardHook = new WinHooksNET.KeyboardHook();
        private WinHooksNET.MouseHook _mouseHook = new WinHooksNET.MouseHook();

        public MainWindow()
        {
            InitializeComponent();

            _keyboardHook.OnKeyboardAction += _keyboardHook_OnKeyboardAction;
            _mouseHook.OnMouseAction += _mouseHook_OnMouseAction;
        }

        void _mouseHook_OnMouseAction(object sender, WinHooksNET.Events.MouseHookEventArgs e)
        {
            String textItem = "Action: " + e.Action.ToString();             //Type of mouse action
            textItem += ", coords: " + e.Coords.ToString();                 //Mouse coordinates
            textItem += ", coordsDelta: " + e.DeltaCoords.ToString();       //Different between actuall and last mouse coords
            textItem += ", mouseWheelState: " + e.WheelAction.ToString();   //WheelAction, if actions is Mouse Wheel
            LB_Mouse.Items.Insert(0, textItem);
        }

        void _keyboardHook_OnKeyboardAction(object sender, WinHooksNET.Events.KeyboardHookEventArgs e)
        {
            String textItem = "Action: " + e.State.ToString();              //Type of keyboard action
            textItem += ", key: " + e.Key.ToString();                       //Key symbol
            textItem += ", isUppercase: " + e.IsUppercase.ToString();       //Is uppercase flag
            LB_Keyboard.Items.Insert(0, textItem);
        }
    }
}
